package eco2automotive.port;
import gnu.io.SerialPort;
/**  
  * Port configuration.
  * @version 1.0
  * @autor Fco. Javier Sánchez Esparza
  *
  */ 
public class Connection {
private int baud;
private int dataBits;
private int stopBits;
private int parity;
private int timeout;
private int flowControlMode;
private String COMname;

/** 
     * Set the config
    * @param COMname the port name    
    */  

public Connection(int baud, int dataBits, int stopBits, int
parity, String COMname) {
super();
this.baud = baud;
this.dataBits = dataBits;
this.stopBits = stopBits;
this.parity = parity;
this.COMname = COMname;
}
/**
 * Constructs a new, Connection object with the default values: </br>
 * baud=9600;</br>
 * </br>dataBits=SerialPort.DATABITS_8;
 * </br>stopBits=SerialPort.STOPBITS_1;;
 * </br>parity=SerialPort.PARITY_NONE;
 * </br>timeout=2000;
 * </br>flowControlMode=SerialPort.FLOWCONTROL_NONE;
 * </br>COMname=null;
 */
public Connection(){
baud=9600;
dataBits=SerialPort.DATABITS_8;
stopBits=SerialPort.STOPBITS_1;;
parity=SerialPort.PARITY_NONE;
timeout=2000;
flowControlMode=SerialPort.FLOWCONTROL_NONE;
COMname=null;
}

/** 
     * Reset the default values
    */  
public void resetDefaultValues(){
baud=9600;
dataBits=SerialPort.DATABITS_8;
stopBits=SerialPort.STOPBITS_1;;
parity=SerialPort.PARITY_NONE;
timeout=2000;
flowControlMode=SerialPort.FLOWCONTROL_NONE;
this.COMname=null;
}
public void setPortName(String s){this.COMname=s;}
public int getDataBits(){return dataBits;}
public int getStopBits(){return stopBits;}
public String getNombrePuerto(){return COMname;}
public int getParity(){return parity;}
public int getBaud(){return baud;}
public int getTimeOut(){return this.timeout;}
public int getFlowControlMode(){return this.flowControlMode;}
}
